home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / IFC_112 / netscape / application / FoundationWindow.java < prev    next >
Encoding:
Text File  |  1999-05-28  |  2.0 KB  |  70 lines  |  [TEXT/CWIE]

  1. // FoundationWindow.java
  2. // By Ned Etcode
  3. // Copyright 1996, 1997 Netscape Communications Corp.  All rights reserved.
  4.  
  5. package netscape.application;
  6.  
  7. import java.awt.Window;
  8. import java.awt.Frame;
  9. import java.awt.Dimension;
  10. import netscape.util.*;
  11.  
  12. /** FoundationFrame is...
  13.   * Subclass of window to allow ifc component in BLANK_TYPE
  14.   * windows.
  15.   * @private
  16.   */
  17. public class FoundationWindow extends java.awt.Window {
  18.     ExternalWindow externalWindow;
  19.  
  20.     public FoundationWindow(java.awt.Frame parent) {
  21.         super(parent);
  22.     }
  23.  
  24.     public boolean handleEvent(java.awt.Event event) {
  25.         Application app = Application.application();
  26.         if (event.id == java.awt.Event.WINDOW_DESTROY) {
  27.             if( app != null && app.eventLoop.shouldProcessSynchronously())
  28.                 externalWindow.hide();
  29.             else {
  30.                 /** Cannot wait. This will block the AWT thread and may cause
  31.                  * a dead lock if the window owner needs to show an alert
  32.                  */
  33.                 externalWindow.rootView().application().performCommandLater(
  34.                     externalWindow, ExternalWindow.HIDE, null, false);
  35.             }
  36.             return true;
  37.         } else {
  38.             return super.handleEvent(event);
  39.         }
  40.     }
  41.  
  42.     public ExternalWindow externalWindow() {
  43.         return externalWindow;
  44.     }
  45.  
  46.     void setExternalWindow(ExternalWindow wFrame) {
  47.         externalWindow = wFrame;
  48.     }
  49.  
  50.     public void layout() {
  51.         java.awt.Dimension size = size();
  52.         java.awt.Insets insets = insets();
  53.         int x = insets.left, y = insets.top,
  54.             w = size.width - (insets.left + insets.right),
  55.             h = size.height - (insets.top + insets.bottom);
  56.  
  57.         if (w > 0 && h > 0) {
  58.             externalWindow.panel().reshape(x, y, w, h);
  59.         }
  60.     }
  61.  
  62.     public java.awt.Dimension minimumSize() {
  63.         if (externalWindow != null) {
  64.             Size size = externalWindow.minSize();
  65.             return new java.awt.Dimension(size.width, size.height);
  66.         } else
  67.             return null;
  68.     }
  69. }
  70.